$(function () {
    let res = myAjax("/home", {}, "get");
    console.log(res);
    if (res != null) {

        setNewsData(res.newsModelList);
        setProductData(res.productModelList);
    }
})

function setNewsData(data) {
    let html = '';
    for (let i = 0; i < data.length; i++) {
        html += ' <div>\n' +
            '                            <div class="font-title single-over">' + data[i].title +
            '                            </div>' +
            '                            <div class="font-content single-over">' + data[i].content+
            '                            </div>' +
        '                        </div>';

    }
    $("#news").html(html);

}

function setProductData(data) {
    let html = '';
    for (let i = 0; i < data.length; i++) {
        html += '<div>\n' +
            '                        <div><img src="' + data[i].imgHref + '"></div>\n' +
            '                        <div class="font-title single-over" onclick="gotodetail('+data[i].id+')">' + data[i].name + '</div>\n' +
            '                        <div class="font-content single-over">' + data[i].content + '</div>\n' +
            '                    </div>';
    }
    $("#product").html(html);
}
function gotodetail(id){
    sessionStorage.setItem("productId",id);
    window.open("/html/product-detail.html");
}